package org.tema.entities;

import java.io.Serializable;
import java.lang.String;
import java.sql.Date;
import java.util.Set;

import javax.persistence.*;

/**
 * Entity implementation class for Entity: TestSpecification
 *
 */
@Entity
@Table(name="TESTSPECIFICATION")
public class TestSpecification implements Serializable {

	
	private int id;
	private String summary;
	private String description;
	private Date creationDate;
	private Date modificationDate;
	private byte[] attachment;
	private static final long serialVersionUID = 1L;
	
	/* Add relational properties for TestSpecification, Testers, TestCases, TestPlans;
	   Reports relationship has been removed because the report is per TestPlan run, Specification
	   if a report's generated for a product not clear for what run an what specification.
	   Appropriate searches need to be added at business layer.
	*/
	protected Product product;
	protected Set<TestCase> testCaseSet;
	protected Report report;
	protected User creator;
	protected User modifier;
	
	
	

	public TestSpecification() {
		super();
	}  
	
	@Id    
	@GeneratedValue
	@Column(name="ID")
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}   
	
	@Column(name="SUMMARY")
	public String getSummary() {
		return this.summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}   
	
	@Column(name="CREATIONDATE")
	public Date getCreationDate() {
		return this.creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}   
	
	@Column(name="MODIFICATIONDATE")
	public Date getModificationDate() {
		return this.modificationDate;
	}

	public void setModificationDate(Date modificationDate) {
		this.modificationDate = modificationDate;
	} 
	
	@Column(name="ATTACHMENT")
	public byte[] getAttachment() {
		return this.attachment;
	}

	public void setAttachment(byte[] attachment) {
		this.attachment = attachment;
	}

	//references from product
	
	@Column(name="DESCRIPTION")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToOne(cascade= {CascadeType.MERGE })
	@JoinColumn(name="PRODUCT_ID", referencedColumnName = "ID")
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	//references to  testCases per testSpecification
	
	@OneToMany( cascade= {CascadeType.PERSIST, CascadeType.MERGE }, mappedBy="specification" )
	public Set<TestCase> getTestCaseSet() {
		return testCaseSet;
	}

	public void setTestCaseSet(Set<TestCase> testCaseSet) {
		this.testCaseSet = testCaseSet;
	}
	
	//reference to report
	@OneToOne( cascade= {CascadeType.PERSIST, CascadeType.MERGE }, mappedBy="specification")
	public Report getReport() {
		return report;
	}

	public void setReport(Report report) {
		this.report = report;
	}

	//reference to user, who is the creator, modifier of a Test Specification
	@ManyToOne ( cascade= {CascadeType.PERSIST, CascadeType.MERGE }, optional = false ) //the specification must have a creator in order to exist
	@JoinColumn(name="CREATOR_ID", referencedColumnName = "ID")
	public User getCreator() {
		return creator;
	}

	public void setCreator(User creator) {
		this.creator = creator;
	}

	@ManyToOne (cascade= {CascadeType.PERSIST, CascadeType.MERGE })//the modifier is not necessary for a test specification to created
	@JoinColumn(name="MODIFIER_ID", referencedColumnName = "ID")
	public User getModifier() {
		return modifier;
	}

	public void setModifier(User modifier) {
		this.modifier = modifier;
	}
   
}
